Skip to content

fix(dify): handle string query response#1922

Open
guslegend0510 wants to merge 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1917-dify-query-string
Open

fix(dify): handle string query response#1922
guslegend0510 wants to merge 1 commit into
agentscope-ai:mainfrom
guslegend0510:fix/issue-1917-dify-query-string

Conversation

@guslegend0510

@guslegend0510 guslegend0510 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.0-SNAPSHOT

Description

Background

The Dify RAG integration fails against real Dify Cloud (api.dify.ai) responses because the top-level query field is returned as a JSON string, while DifyResponse.Query only supported the object form. This caused DifyResponse deserialization to fail and made kb_search results/references empty.

Purpose

Make the Dify response model compatible with both query: "..." and query: { "content": "..." } payloads so retrieval works reliably with real Dify Cloud deployments.

Changes

  • Add a delegating Jackson creator to DifyResponse.Query so string payloads can be deserialized.
  • Keep the existing bean-style object mapping so both response shapes remain supported.
  • Add regression tests for both string and object query payloads.

How to test

  • mvn -pl agentscope-extensions/agentscope-extensions-rag/agentscope-extensions-rag-dify -am -Dtest=DifyRAGClientTest test

Related issue

@guslegend0510
guslegend0510 requested a review from a team June 25, 2026 15:30
@guslegend0510
guslegend0510 force-pushed the fix/issue-1917-dify-query-string branch from 7b69b7b to 9b0f781 Compare June 26, 2026 02:29
@itxaiohanglover

Copy link
Copy Markdown
Contributor

Clean fix — using @JsonCreator with DELEGATING mode is the right approach here, and I like that you kept the object form working too. Test coverage for both string and object query formats is great. Looks good to me.

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/ext/rag RAG extension implementations labels Jul 11, 2026

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Fixes Dify RAG query field to handle both string and object forms via @JsonCreator. Clean fix with test coverage. Minor: Javadoc pre block appears unclosed.

(inline comments could not be attached — line numbers fell outside PR hunks. See archived report.)

@mars171

mars171 commented Jul 17, 2026

Copy link
Copy Markdown

关于 CI 失败原因的说明(下游使用方反馈)

我们在 RuoYi 侧集成 agentscope-extensions-rag-dify 时跟进了本 PR / #1917

结论

  • 本 PR 的 Dify 修复本身看起来没问题Query.fromString + @JsonCreator(DELEGATING),兼容 string / object 两种 query 形态,与我们本地 shadow 方案一致)。
  • 当前 CI 红灯不是 rag-dify 模块测试失败,而是全仓流水线里无关的 flaky / 环境问题导致 build (ubuntu-latest) 失败,Windows 随之 cancelled。

我们核对到的失败点

1. 较新的 run(如 28213304132)

  • 模块:agentscope-core
  • 用例:SubAgentToolTimeoutRetryIntegrationTest.oldAgentIsStopped
  • 断言:Expected exactly 1 tool invocation, got 0
  • DifyResponse / rag-dify 无关

2. 较早的 run(如 28181432978)

  • 模块:agentscope-harness
  • 用例:HarnessAgentTest.runtimeContextNullInputGetsDefaultSessionAndSandbox
  • 错误:Failed to close extension context / 删除 /tmp/junit-... 临时目录失败(DirectoryNotEmptyException
  • 同样与 Dify 补丁 无关

影响

建议

  1. 对本 PR 做一次 re-run,或 rebase 到最新 main 后再跑 CI。
  2. 若上述 core/harness 用例仍 flaky,建议与本 PR 解耦(单独修 flaky / 临时排除),避免阻断这个对 Dify Cloud 很关键的兼容性修复。
  3. 合并后请尽早发包含该修复的正式版(或至少 SNAPSHOT 可验证),方便下游去掉 shadow。

感谢维护!本评论仅作下游排查反馈,无催促之意。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ext/rag RAG extension implementations bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Dify Cloud 检索接口 query 字段返回字符串,导致 DifyResponse 反序列化失败(kb_search 对 api.dify.ai 引用恒为空)

5 participants